<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('上传正式合同')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: jasny-bootstrap-css" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
	<style>
		.file-preview {
		    padding: 0;
		    margin-bottom: 0;
		    border-radius: 0;
		    border: none;
		}
		
		.krajee-default.file-preview-frame {
		    margin-right: 20px;
		    padding: 0;
		    border: none;
		    box-shadow: none;
		}
		
		.krajee-default.file-preview-frame:not(.file-preview-error):hover {
		    border: none;
		    box-shadow: none;
		}
		
		.krajee-default .file-footer-caption {
			margin-bottom: 0;
		}
		
		.krajee-default.file-preview-frame .file-thumbnail-footer {
		    height: auto;
		}
		
		.krajee-default .file-caption-info {
			width: auto;
		}
		
		.kv-upload-progress .progress {
			margin-top: 0;
		}
		
		.krajee-default.file-preview-frame .kv-file-content,
		.krajee-default .file-size-info,
		.krajee-default .file-upload-indicator,
		.file-input .kv-file-upload,
		.file-input .kv-file-zoom {
			display: none;
		}
		
		.file-input .kv-file-remove {
			position: absolute;
			top: 3px;
			right: -15px;
			height: 14px;
			padding: 0;
			margin: 0;
			border: none;
			background: none;
		}
		
		.file-input .kv-file-remove:active, 
		.file-input .kv-file-remove:focus {
			background: none;
			outline: none;
			box-shadow: none;
		}
		
		.file-input .kv-file-remove .glyphicon-trash {
			color: red;
		}
	</style>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-xmxq-edit" th:object="${gcProjectXmxq}" enctype="multipart/form-data" method="post">
            <input name="id" th:field="*{id}" type="hidden">
            <input name="orderNo" th:field="*{orderNo}" type="hidden">
            <input name="gcProjectid" th:field="*{gcProjectid}" type="hidden">
            <input type="hidden" id="zhengsht" name="zhengsht" th:value="*{zhengsht}" />
            <input name="xmmc" th:field="*{xmmc}" type="hidden" >
            <input name="xmdz" th:field="*{xmdz}" type="hidden" >
            <input name="htje" th:field="*{htje}" type="hidden" >
            <input name="kpsl" th:field="*{kpsl}" type="hidden" >
            <input name="fkfs" th:field="*{fkfs}" type="hidden" >
            <div class="form-group">    
                <label class="col-sm-2 control-label">项目名称：</label>
                <div class="col-sm-4" style="top: 8px">
                	<span th:text="*{xmmc}" >
                </div>
                <label class="col-sm-2 control-label">项目地址：</label>
                <div class="col-sm-4" style="top: 8px">
                    <span th:text="*{xmdz}" >
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label">合同金额：</label>
                <div class="col-sm-4" style="top: 8px">
                    <span th:text="*{htje}" >
                </div>
                <label class="col-sm-2 control-label">开票税率：</label>
                <div class="col-sm-4" style="top: 8px">
                	<span th:text="*{kpsl}" ></span>%
                </div>
            </div>
            <div class="form-group"> 
                <label class="col-sm-2 control-label is-required">签订日期：</label>
                <div class="col-sm-4">
                    <div class="input-group date">
                        <input name="riq" th:value="${#dates.format(gcProjectXmxq.riq, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" autoComplete="off" required >
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label">支付方式：</label>
                <div class="col-sm-10" style="top: 8px">
                	<span th:text="*{fkfs}" >
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">正式合同文件：</label>
                <div class="col-sm-10" style="margin-top: 8px;" id="zhengshtlink">
                </div>
            </div>
            <div class="form-group">
	            <label class="col-sm-2 control-label font-noraml">正式合同文件：</label>
	            <div class="col-sm-10">
	            	<div class="file-loading">
		            	<input id="multipleFile" name="files" type="file" multiple>
		        	</div>
	            </div>
            </div>
        </form>
    </div>
    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: jasny-bootstrap-js" />
    <script th:src="@{/ruoyi/base64.min.js?v=20231208}"></script>
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <th:block th:include="include :: bootstrap-suggest-js" />
    <th:block th:include="include :: bootstrap-typeahead-js" />
    <script th:inline="javascript">
        var prefix = ctx + "gcgl/xmxq";
        $("#form-xmxq-edit").validate({
            focusCleanup: true
        });
        
        $("input[name='riq']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        
        $(function() {
			var zhengsht = $("#zhengsht").val();
        	
        	var n=zhengsht.split(",");
        	for(var i=0;i<n.length;i++){
//         		var url = "http://lkgnews.cn:8012/onlinePreview?url="+encodeURIComponent(Base64.encode(n[i]));
        		var url = n[i];
        		$("#zhengshtlink").append("<a href='"+url+"' target='_blank' >"+n[i]+"</a><br>");
        	}
        	
        	// 多图上传
	       $("#multipleFile").fileinput({
	           uploadUrl: "/gcgl/xmxq/uploads",
	           uploadAsync: false,
	           showClose: false,
	           showCancel: false,
	           dropZoneEnabled: false,
	           buttonLabelClass: ''
	       }).on('filebatchuploadsuccess', function (event, data, previewId, index) {
	       	var rsp = data.response;
	           log.info("reutrn fileNames：" + rsp.fileNames)
			   $("#zhengsht").val(rsp.fileNames);
	       }).on('fileremoved', function (event, id, index) {
	           $("input[name='" + event.currentTarget.id + "']").val('')
	       })
        });

        function submitHandler() {
            if ($.validate.form()) {
            	
            	var form = document.getElementById("form-xmxq-edit");
                var file = new FormData(form);
                $.ajax({
                    url: "/gcgl/xmxq/editZsht",
                    type: "POST",
                    processData:false,
                    contentType:false,
                    //重要部分，data的传的是整个表单，不用大括号包裹；不用自定义变量名
                    data:file,
                    success: function (data) {
                    	$.operate.saveReload(data);
                    },
                    error: function (data) {
                    	$.operate.saveReload(data);
                    }
                })
            	
                //$.operate.save(prefix + "/edit", $('#form-xmxq-edit').serialize());
            }
        }

    </script>
</body>
</html>